package com.xq.tmall.agu.schedule;

import com.xq.tmall.agu.ferign.IpValidSpider;
import com.xq.tmall.agu.job.ITimerJob;
import com.xq.tmall.util.DateUtil;
import com.xq.tmall.util.ITimeJobFactory;
import com.xq.tmall.util.SpringContextUtil;
import com.xq.tmall.util.TradingDateUtil;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 调度作业
 *
 * @author chenguoxiang
 * @create 2019-03-26 17:00
 **/
@Slf4j
public class ScheduleThread implements Runnable {

    void jobProcess() throws Exception {
        LocalDateTime dateTime = LocalDateTime.now();
        // 周末不执行
        boolean isWeek = DateUtil.isWeekend(dateTime);
        LocalDateTime now = LocalDateTime.now();
        LocalTime currentTime = now.toLocalTime();
        if (currentTime.getHour() == 9 && currentTime.getMinute() == 25 && !isWeek) {
            // 每天9点25分开始获取竞价量
           // ITimeJobFactory.getJob(ITimeJobFactory.TIMEJOB.INDEX).execute(ITimerJob.COMMAND.START);
        }

    }

    @Override
    public void run() {
        try {
            jobProcess();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
